const express = require('express')
const bodyParser = require('body-parser')

const app = express()
// bodyParser 中间件 用来格式化参数的
app.use(bodyParser.json())
app.use(bodyParser.urlencoded({extended:false}))

app.all('*', function (req, res, next) {
   res.header("Access-Control-Allow-Origin", "*");
   res.header("Access-Control-Allow-Headers", "Origin, X-Requested-With, Content-Type, Accept");
   res.header("Access-Control-Allow-Methods", "PUT,POST,GET,DELETE,OPTIONS");
   res.header("X-Powered-By", ' 3.2.1')
   res.header("Content-Type", "application/json;charset=utf-8");
   next();
})

app.post('/home', (req, res) => {
   console.log('------------------', req.url)
   console.log(req.body)
   console.log(req.query)
   res.send('hello')
})

app.listen(9528, () => {
   console.log(`服务器启动成功，地址是${'http://127.0.0.1:9528'}`)
})